<?php

namespace App\System\Fina\Repositories;

use App\Module\Api\Controllers\Request\TableRequest;
use App\System\Base\Helpers\Traits\SinglePattern;
use App\System\Base\Repositories\Repository;
use App\System\Fina\Model\FinaBankInfo;


class FinaBankInfoRepository extends Repository
{
    use SinglePattern;

    /**
     * 银行卡列表
     * @param $request object
     * @return mixed
     */
    public function getList(TableRequest $request){

        $data = FinaBankInfo::select(['*'])
            ->orderBy($request->orderBy,$request->orderType)
            ->paginate($request->limit,['*'],'page',$request->page);
        foreach($data as $v) {
            $item = [];
            $item['id'] = $v->id;
            $item['name'] = $v->bank_name;
            $return['categorys'][] = $item;
        }
        $return['total'] =$data->total();
        return $return;
    }

    /**
     * 银行卡列表
     * @return \Illuminate\Database\Eloquent\Collection|static[]
     */
    public function bankList(){
        return FinaBankInfo::get();
    }
}